package sg.edu.nus.iss.phoenix.presenterproducer.service;

import java.sql.SQLException;
import java.util.ArrayList;

import sg.edu.nus.iss.phoenix.dao.DAOFactory;
import sg.edu.nus.iss.phoenix.presenterproducer.dao.PresenterProducerDAO;
import sg.edu.nus.iss.phoenix.presenterproducer.dao.PresenterDAO;
import sg.edu.nus.iss.phoenix.presenterproducer.dao.ProducerDAO;
import sg.edu.nus.iss.phoenix.authenticate.entity.Role;
import sg.edu.nus.iss.phoenix.authenticate.entity.User;

public class ReviewSelectPresenterProducerService {

	DAOFactory factory;
	PresenterProducerDAO ppdao;
	PresenterDAO presenterdao;
	ProducerDAO producerdao;
	
	public ReviewSelectPresenterProducerService() {
		super();
		factory = new DAOFactory();
		ppdao = factory.getPresenterProducerDAO();
		presenterdao = factory.getPresenterDAO();
		producerdao = factory.getProducerDAO();
	}
	
	public ArrayList<User> searchPresenter(User pp,Role role) {
		ArrayList<User> currentList = new ArrayList<User>();
		System.out.println(" ReviewSelectPresenterProducerService :: searchPresenter :: Before presenterdao");
		try {
			currentList = (ArrayList<User>) presenterdao.searchPresenter(pp,role);
			System.out.println(" ReviewSelectPresenterProducerService :: searchPresenter :: After presenterdao");
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return currentList;
	}
	
	public ArrayList<User> searchAllPresenter(Role role) {
		ArrayList<User> currentList = new ArrayList<User>();

		try {
			currentList = (ArrayList<User>) presenterdao.searchAllPresenter(role);
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

		return currentList;
	}
	
	public ArrayList<User> searchProducer(User pp,Role role) {
		ArrayList<User> currentList = new ArrayList<User>();

		try {
			currentList = (ArrayList<User>) producerdao.searchProducer(pp,role);
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

		return currentList;
	}
	
	public ArrayList<User> searchAllProducer(Role role) {
		ArrayList<User> currentList = new ArrayList<User>();

		try {
			currentList = (ArrayList<User>) producerdao.searchAllProducer(role);
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

		return currentList;
	}
	
}
